<?php
// +----------------------------------------------------------------------
// | Author: 发仔 <i@fazi.me> 
// +----------------------------------------------------------------------

namespace app\admin\controller;

use think\Db;

class Used extends Base
{
	protected $id = 'car_use_id';
	protected $table = 'car_use';
	
	public function department() {
		
		$id = input('param.id/d');
		$list = Db::name('department')->where('car_use_id',$id)->select();
		
		return json($list);
		
	}
	
	protected function search() {
		
		$P = input('param.');
		$where = [];
		//公务只能看公务订单
		if( $this->user['official'] ){
			$where['quota'] = ['>',0];
		}
		$P['name'] && $where['name'] = ['like',"%{$P['name']}%"];
		
		//弹出层搜索
		$op = input('param.op');
		if(in_array($op, ['search','bind','unbind']) ) {
			$this->assign('notPopup',0);
		}
		$this->assign('op',$op);
		
		return $where;
	}
	
		
	protected function options($item = []) {
		
		$used_types = config('base.used_types');
		$this->assign('car_use_types',TplOptions($used_types,$item['car_use_type']));
		
		return $item;	
	}
}
